import Main from '../layout/main.vue'
import Util from '../libs/util'
const _import = require('./_import_production');
export const loginRouter = {
  path: '/login',
  name: 'login',
  meta: {
    title: '登录'
  },
  beforeEnter: (to, from, next) => {
  if (Util.user()
 )
{
  next({
    name: 'home_index'
  })
}
else
{
  next()
}
},
component:_import('login')
}

export const page404 = {
  path: '/*',
  name: 'error_404',
  meta: {
    title: '404-页面不存在'
  },
  component: _import('errors/error_404')
}

export const page403 = {
  path: '/403',
  name: 'error_403',
  meta: {
    title: '403-权限不足'
  },
  component:_import('errors/error_403')
}

export const appRouter = [
  {
    path: '/home',
    name: 'home',
    component: Main,
    meta: {
      requireAuth: true,
      icon: 'ios-speedometer',
      title: '首页'
    },
    children: [
      {
        path: 'index',
        name: 'home_index',
        meta: {
          icon: 'ios-speedometer',
          title: '首页'
        },
        component: _import('home/home')
  }
]
},
{
  path: '/admin',
    name:'admin',
    component:Main,
    meta:
  {
    requireAuth: true,
      icon:'ios-gear',
      title:'系统管理',
      // requirePermission:'create-admin'
  },
  children: [
    {
      path: 'admin',
      name: 'admin_index',
      meta: {
        icon: 'person-stalker',
        breadCrumbs: [{name: '后台人员管理', href: '/admin/admin', active: true}],
        title: '后台人员管理',
      },
      component: _import('admin/admin')
  },
  {
    path: 'property',
      name: 'property_index',
    meta: {
    icon: 'ios-settings-strong',
    breadCrumbs: [{name: '系统参数', href: '/admin/property', active: true}],
      title: '系统参数',
  },
    component: _import('property/index')
  },

]
},
  {
    path: '/components',
    name:'components',
    component:Main,
    meta:
      {
        requireAuth: true,
        icon:'levels',
        title:'组件应用',
        // requirePermission:'create-admin'
      },
    children: [
      {
        path: 'audio',
        name: 'components_audio',
        meta: {
          icon: 'headphone',
          breadCrumbs: [{name: '音频组件', href: '/components/audio', active: true}],
          title: '音频组件查看',
        },
        component: _import('audio/index')
      }, {
        path: 'emoji',
        name: 'components_emoji',
        meta: {
          icon: 'social-freebsd-devil',
          breadCrumbs: [{name: 'emoji组件', href: '/components/emoji', active: true}],
          title: 'emoji组件查看',
        },
        component: _import('emoji/index')
      }
    ]
  },

]

export const routers = [
    loginRouter,
    ...appRouter,
  page403,
  page404,
  ]

